package com.yubest.junit.asyntask;

import java.util.List;
import java.util.Random;

/**
 * 任务4
 *
 * @Author: hweiyu
 * @Date: 2022/10/27 16:35
 */
public class MyTask4 implements Task {

    private List<Integer> ids;

    public MyTask4(List<Integer> ids) {
        this.ids = ids;
    }

    @Override
    public int exec() {
        System.out.println(Thread.currentThread().getId() + " MyTask4 开始执行");
        //1000到3000毫秒
        int sleep = new Random().nextInt(3000 - 1000 + 1) + 1000;
        try {
            Thread.sleep(sleep);
            System.out.println(Thread.currentThread().getId() + " MyTask4 执行耗时：" + sleep);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println(Thread.currentThread().getId() + " MyTask4 执行完成");
        return sleep;
    }
}
